// 只保留ACE-Step音乐制作大模型相关设置，无背景音乐相关内容

// 页面加载时自动读取API密钥
document.addEventListener('DOMContentLoaded', function() {
    const savedApiKey = localStorage.getItem('acestepApiKey');
    if (savedApiKey) {
        document.getElementById('acestepApiKey').value = savedApiKey;
    }
});

function toggleSettings() {
    const modal = document.getElementById('settingsModal');
    if (modal.style.display === 'flex') {
        modal.style.display = 'none';
    } else {
        modal.style.display = 'flex';
    }
}

// 保存设置
function saveSettings() {
    const apiKey = document.getElementById('acestepApiKey').value.trim();
    if (!apiKey) {
        alert('请输入有效的ACE-Step API密钥');
        return;
    }
    localStorage.setItem('acestepApiKey', apiKey);
    alert('设置已保存成功');
    toggleSettings();
}

// 点击弹窗外关闭
document.getElementById('settingsModal').addEventListener('click', function (e) {
    if (e.target === this) {
        toggleSettings();
    }
});